<extend name="Index/index"/>

<block name="main">
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/Home/css/BBSinvit.css">
	
	<div id="wp" class="wp">

	<script type="text/javascript">var fid = parseInt('37'), tid = parseInt('4823610');</script>

	
	<script type="text/javascript">zoomstatus = parseInt(1);var imagemaxwidth = '720';var aimgcount = new Array();</script>

	<style id="diy_style" type="text/css"></style>
	<!--[diy=diynavtop]--><div id="diynavtop" class="area"></div><!--[/diy]-->
	<div id="pt" class="bm cl">
	<div class="z">
	<a href="http://www.miui.com/index.php" class="nvhm" title="首页">MIUI论坛</a> <em>›</em> <a href="<{:U('BBStype/bbsView',array('tid'=>$TypeData01['tid']))}>"><{$TypeData01.tname}></a> <em>›</em> <a href="<{:U('BBStype/bbsView',array('tid'=>$TypeData02['tid']))}>"><{$TypeData02.tname}></a> <em>›</em> <a><{$InitData.intitle}></a>
	</div>
	</div>
	<div class="miui_b_p"></div>
	<style id="diy_style" type="text/css"></style>
	<div class="wp">
	<!--[diy=diy1]--><div id="diy1" class="area"></div><!--[/diy]-->
	</div>
	<div id="ct" class="wp cl">
		<div id="pgt" class="pgs mbm cl ">
			<button id="CLbtn">插楼评论</button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			<button id="like" >收藏</button>
			<label style="display:none;" id="inid"><{$InitData.inid}></label>
			<label style="display:none;" id="title"><{$InitData.intitle}></label>
			<label style="display:none;" id="session"><{$_SESSION['username']}></label>
			<label style="display:none;" id="tname"><{$TypeData02.tname}></label>
			<label style="display:none;" id="time"><{$InitData.intime}></label>
		</div>
<script type="text/javascript">
	$('#like').on('click',function(){
		// 判断是否已登录
		if ($('#session').html() == '') {
			alert('请先登录!');
		} else {
			// ajax实现无刷新收藏
			$.ajax({
				type:'POST',
				url:"<{:U('Like/ajax')}>",
				// 获得帖子ID
				data:"intitle="+$('#title').html()+"&session="+$('#session').html()+"&tname="+$('#tname').html()+"&time="+$('#time').html()+"&inid="+$('#inid').html(),
				success:function(data){
					// 请求成功 判断是否已经收藏
					if (data == '1') {
						alert('请不要重复收藏!');
					} else if(data == '0'){
						$('#like').html('已收藏');
					}
				},
				
			})
		}
	})
</script>
		<!-- 帖子作者 -->
		<div class="BBSinvitContent">
			<table>
					<tr><td></td><td><span class="BBSfloorLZ">楼主</span></td></tr>
					<tr class="BbsLz">
						<td class="LZhead">
							<ul>
								<li class="TXhead"><a href="<{:U('Space/index',array('uid'=>$UserData['uid']))}>"><img src="__PUBLIC__/Home/image/space/touxiang/<{$UserData.userimage}>"></a></li>
								<li class="LZname"><{$UserData.username}></li>
								<li class="LZlv">等级:<{$UserData.score}></li>
								<li class="LeftInfo"><span class="left01">积分:</span><span class="left02"><{$UserData.score}></span></li>
								<li class="LeftInfo"><span class="left01">签到:</span><span class="left02">10</span></li>
								<li class="LeftInfo"><span class="left01">发帖数:</span><span class="left02">10</span></li>
							</ul>
						</td>
						<td class="LZcontent">
							<ul>
								<li class="BbsTitle"> 【 <{$InitData.intitle}> 】 </li>
								<li>
									<div class="LZinvit">
										<{$InitData.intext|htmlspecialchars_decode}>
									</div>
								</li>
							</ul>
							
						</td>
					</tr>
					<tr class="BBSreplay">
						<table style="width:650px;margin-left:150px;" class="BBStable">
					            <tr>
					                <th><span class="span"><input type="hidden" value="<{$UserData.username}>"><button id="LzUid" value="<{$UserData.uid}>" class="REbtn">回复楼主</button></span></th>
					                <th colspan="3"></th>
					                <th>操作</th>
					            </tr>
								<volist name="initRep" id="vo">
					            <tr>
					                
					                <td colspan="4" style="color:#1A98E8;"><span><{$vo.username}></span><span style="color:#000;">回复:</span><span><{$vo.rename}>&nbsp;&nbsp;</span><span style="color:#000;"><{$vo.rtext}></span></td>
					                <td class="ReDe">
					                    <input type="hidden" value="<{$vo.username}>">
					                    <span class="rere">回复</span>
										<input type="hidden" value="<{$vo.uid}>">
					                    <span>&nbsp;&nbsp;&nbsp;</span>
					                    <span class="dede">删除</span>
					                    <input type="hidden" value="<{$vo.rid}>">
					                </td>
					            </tr>
								</volist>
					           <tr class="REtr"><td colspan="5"><input type="hidden" value="0"><input class="replay" type="text" name="rtext"><button class="FSbtn">发送</button></td></tr>
					    </table>
					</tr>
				
			</table>
		</div>
		<!-- 评论 -->
		<volist name="ComData" id="vo" key="k">
		<div class="BBSinvitContent">
			<table>
					<tr><td></td><td><span class="Ctime">发表于[ <{$vo.ctime|date='Y年m月d日 H:i:s',###}> ]</span><input type="hidden" value="<{$vo.uid}>"><span class="BBSfloor"><{$k + 1}>楼</span><input type="hidden" value="<{$vo.cid}>"></td></tr>
					<tr style="height:20px;"><td></td></tr>
					<tr class="BbsLz">
						<td class="LZhead">
							<ul>
								<li class="TXhead"><a href="<{:U('Space/index',array('uid'=>$vo['uid']))}>"><img src="__PUBLIC__/Home/image/space/touxiang/<{$vo.userimage}>"></a></li>
								<li class="LZname"><{$vo.username}></li>
								<li class="LZlv">等级:<{$vo.score}></li>
								<li class="LeftInfo"><span class="left01">积分:</span><span class="left02"><{$vo.score}></span></li>
								<li class="LeftInfo"><span class="left01">签到</span><span class="left02">10</span></li>
								<li class="LeftInfo"><span class="left01">发帖数</span><span class="left02">10</span></li>
							</ul>
						</td>
						<td class="LZcontent">
							<ul>
								
								<li>
									<div class="LZinvit">
										<{$vo.ctext|htmlspecialchars_decode}>
									</div>
								</li>
							</ul>
							
						</td>
					</tr>
					<tr class="BBSreplay">
						<table style="width:650px;margin-left:150px;" class="BBStable">
					            <tr>
					                <th><span class="span"><input type="hidden" value="<{$vo.username}>"><button value="<{$vo.uid}>" class="REbtn">回复[<{$k + 1}>楼]</button></span></th>
					                <th>&nbsp;</th>
					                <th></th>
					                <th></th>
					                <th>操作</th>
					            </tr>
								<volist name="vo['replay']" id="v">
					            <tr>
					                
					                <td colspan="4" style="color:#1A98E8;"><span><{$v.username}></span><span style="color:#000;">回复:</span><span><{$v.rename}>&nbsp;&nbsp;</span><span style="color:#000;"><{$v.rtext}></span></td>
					                <td class="ReDe">
					                	<input type="hidden" value="<{$v.username}>">
					                    <span class="rere">回复</span>
										<input type="hidden" value="<{$v.uid}>">
					                    <span>&nbsp;&nbsp;&nbsp;</span>
					                    <span class="dede">删除</span>
					                    <input type="hidden" value="<{$v.rid}>">
					                </td>
					            </tr>
								</volist>
					           	<tr class="REtr"><td colspan="5"><input type="hidden" value="<{$vo.cid}>"><input class="replay" type="text" name="rtext"><button class="FSbtn">发送</button></td></tr>
					    </table>
					</tr>
				
			</table>
		</div>
		</volist>
		<{$page}>
	</div>

	<script type="text/javascript">
		$(function(){
			//点击回复楼主
			$('.REbtn').click(function(){
				reuid = $(this).val();
				rename = $(this).prev().val();
				$('.REtr').show(100);
			})
			//点击回复他人
			$('.rere').click(function(){
				reuid = $(this).next().val();
				rename = $(this).prev().val();
				$('.REtr').show(100);
			})
			//点击发送
			$('.FSbtn').click(function(){
				$('.REtr').hide(100);
				var inid = $('#BBSinid').val();
				var rtext = $(this).prev().val();
				var cid = $(this).prev().prev().val();
				var _this = $(this);
				
				$.ajax({
					type:'POST',
					url:"<{:U('BBScomment/BBSinvitReAdd')}>",
					data:{inid:inid,reuid:reuid,rtext:rtext,cid:cid,rename:rename},
					async:false,
					success:function(data){

						if(data == '1'){
							alert('请先登录');
						}else{
							$('<tr><td colspan="4" style="color:#1A98E8;"><span>'+data['username']+'</span><span style="color:#000;">回复:</span><span>'+rename+'&nbsp;&nbsp;</span><span style="color:#000;">'+rtext+'</span></td><td class="ReDe"><input type="hidden" value="'+data['username']+'"><span class="rere">回复</span><input type="hidden" value="'+data['uid']+'"><span>&nbsp;&nbsp;&nbsp;</span><span class="dede">删除</span></td></tr>').insertBefore(_this.parent('td').parent('tr'));
						}
						
					},
					dataType:'json',
				})
			})
		})
	</script>
	
</block>



<block name="left">
	<!-- 删除回复 -->
	<script type="text/javascript">
		$(function(){
			$('.dede').hide();
			var NowU = "<{$_SESSION['uid']}>";
			var LzUid = $('#LzUid').val();
			if(NowU == LzUid){
				$('.dede').show();
			}else{
				$('.ReDe').mouseover(function(){
					var uid = $(this).children().eq(2).val();
					if(NowU == uid){
						$(this).children().eq(4).show();
					}
				})
				$('.ReDe').mouseout(function(){
					$(this).children().eq(4).hide();
				})
			}

			
			//点击删除
			$('.dede').click(function(){
				var rid = $(this).next().val();
				var _this = $(this).parent('td').parent('tr');
				
				$.ajax({
					type:'GET',
					url:"<{:U('BBScomment/BBSinvitReDel')}>",
					data:'rid='+rid,
					async:false,
					success:function(data){
						_this.hide();
					},
				})
			})
		})
	</script>
	<!-- 删除评论 -->
	<script>
	$(function(){
		var NowU = "<{$_SESSION['uid']}>";
		var LzUid = $('#LzUid').val();

		$('.BBSfloor').mouseover(function(){
			LouC = $(this).html();
			var uid = $(this).prev().val();
			if( (NowU == LzUid)||(NowU == uid) ){
				$(this).html('删除');
				$(this).css({ cursor: "pointer", background: "#FE0000" });
				$(this).click(function(){
					var _this = $(this).parent('td').parentsUntil('#ct');
					var cid = $(this).next().val();
					$.ajax({
						type:'GET',
						url:"<{:U('BBScomment/BBScommentDel')}>",
						data:'cid='+cid,
						async:false,
						success:function(data){
							console.log(data);
							_this.hide();
						},
					})
				})
			}	
		})

		$('.BBSfloor').mouseout(function(){
			$(this).html(LouC);
			$(this).css("background","#1A98E8");
		})
	})
	</script>
</block>
<block name="foot">
	<div id="footEdit">
		<form action="<{:U('BBScomment/BSScomment')}>" method="post">

			<script id="container" name="ctext" type="text/plain">

			</script>
			<input id="BBSinid" type="hidden" name="inid" value="<{$InitData['inid']}>">
			<button>提交</button>
		</form>
		<script type="text/javascript" src="__PUBLIC__/Home/UEditor/ueditor.config.js"></script>
		<script type="text/javascript" src="__PUBLIC__/Home/UEditor/ueditor.all.js"></script>
		<script type="text/javascript">
			var ue = UE.getEditor('container');
		</script>
	</div>
</block>